SET PROC TO SOSPRO
SET PROC TO BOXPROC

SET COLO TO W+*/B
DO START

cKet = 'Updating price of drugs and dispos ...'
@10,(80-LEN(cKet))/2 SAY cKet

DR = 'N:'
F1 = 'PUR_DRUG'
F11= 'PURDRCD'
F2 = 'DRUGS'
F3 = 'PUR_DISP'
F31= 'PURDSCD'
F4 = 'DISPOS'

SET EXCLU OFF

SELE 1
USE &DR&F1 INDE &DR&F11
SELE 2
USE &DR&F2 INDE &DR&F2
SELE 3
USE &DR&F3 INDE &DR&F31
SELE 4
USE &DR&F4 INDE &DR&F4

STOR SPAC(5) TO cCode
STOR 0       TO nPrice

SELE 1
DO WHIL .NOT. EOF()
   cCode = DRUG_CODE
   DO WHIL DRUG_CODE = cCode .AND. .NOT. EOF()
      SKIP
   ENDD
   SKIP -1
   IF QANT_PURCH#0
      nPrice = NET_PURCH / QANT_PURCH
      SELE 2
      SEEK cCode
      IF .NOT. EOF()
         nPrice = nPrice / BUY_SELL_R
         IF REC_LOCK()
            REPL EMP_PRICE WITH nPrice
         ENDI
         UNLOCK
      ENDI
   ENDIF
   SELE 1
   SKIP
ENDD

SELE 3
DO WHIL .NOT. EOF()
   cCode = DISP_CODE
   DO WHIL DISP_CODE = cCode .AND. .NOT. EOF()
      SKIP
   ENDD
   SKIP -1
   IF QANT_PURCH#0
      nPrice = NET_PURCH / QANT_PURCH
      SELE 4
      SEEK cCode
      IF .NOT. EOF()
         nPrice = nPrice / BUY_SELL_R
         IF REC_LOCK()
            REPL EMP_PRICE WITH nPrice
         ENDI
         UNLOCK
      ENDI
   ENDIF
   SELE 3
   SKIP
ENDD
CLOS ALL
SET COLO TO
CLEA
RETU
